package com.lge.qcontact.receiver;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;

import com.lge.qcontact.MainActivity;
import com.lge.qcontact.R;

/**
 * 
 * @author project
 * 백그라운드 서비스에 의해 로컬 DB가 변경되었을 경우 
 * 진동과 함께 상태바에 메세지 출력.
 */
public class DBChangedListenReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context arg0, Intent arg1) {
		// TODO Auto-generated method stub
		Vibrator vibrator = (Vibrator)arg0.getSystemService(Context.VIBRATOR_SERVICE);
		vibrator.vibrate(1000);
		
		NotificationManager nm = (NotificationManager)arg0.getSystemService(Context.NOTIFICATION_SERVICE);
		notifyMessage(nm, "hihi", "i'msohigh", arg0, arg1);
	}
	
	private void notifyMessage(NotificationManager nm, String title, String msg,Context context,Intent intent)
	{
		Notification noti = new Notification(R.drawable.kim,msg,System.currentTimeMillis());
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
		noti.defaults = Notification.DEFAULT_ALL;
		noti.setLatestEventInfo(context, title, msg, pendingIntent);
		noti.number =0;
		nm.notify(5555,noti);
	}

}
